package com.bdqn.t362.user.dao.impl;

import com.bdqn.t362.common.dao.BaseDao;
import com.bdqn.t362.user.dao.UserDao;
import com.bdqn.t362.user.entity.UserEntity;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author lqm
 * @ClassName UserDaoImpl
 * @description: TODO
 */
public class UserDaoImpl extends BaseDao implements UserDao {

    @Override
    public UserEntity findByAccountAndPwd(String account, String pwd) {
        String sqlStr = "SELECT * FROM `t_sys_user` WHERE `account`=? AND `password`=?";
        ResultSet rs = executeQuery(sqlStr, account, pwd);
        UserEntity userEntity = null;
        try {
            while (rs.next()) {
                userEntity = new UserEntity(rs.getInt(1),
                        rs.getString(2), rs.getString(3),
                        rs.getString(4), rs.getString(5),
                        rs.getString(6), rs.getString(7),
                        rs.getString(8), rs.getInt(9),
                        rs.getString(10), rs.getString(11),
                        rs.getString(12), rs.getString(13)
                );
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            closeConnection(null, null, rs);
        }
        return userEntity;
    }
}
